package com.example.understand_compose1.fet_jetpack_compose_news.data.app_result

// not mix up with internal Result
sealed class AppResult<out R> {
    data class Success<out T>(val data: T): AppResult<T>()
    data class Error(val exception: Exception): AppResult<Nothing>()
}

fun<T> AppResult<T>.successOr(fallback: T): T {
    return (this as? AppResult.Success<T>)?.data ?: fallback
}